<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="/jsp/header.jsp" />
<jsp:include page="/jsp/footer.jsp" />
<title>Book Search</title>

</head>
<body>
	<div class="page2" style="width: 880px; height: 295px">
		<form id="bookSearchForm" action="${WEB_BASE}BookSearch">
			<input type="text" name="queryName" id="queryNameid" class="required" />
			<select name="searchType" class="bsSelect1">
				<option value="0">Start with</option>
				<option value="1">IS</option>
				<option value="2">End with</option>
				<option value="3">Contains</option>
			</select> <select name="searchColumn" class="bsSelect2">
				<option value="Author">Book author</option>
				<option value="Title">Book title</option>
				<option value="BillNo">Bill Number</option>
				<option value="Source">Book Source</option>
				<option value="ISBN">ISBN</option>
			</select> <input type="submit" value="Search" class="bsSearch" id="bsSearchid" />
		</form>
		<div id="bsContent2">
			<img src="${WEB_BASE}images/bookmarks_64.png" alt="bookmarks"
				align="right" />
		</div>
		<div style="overflow-y: scroll;width: 878px;height: 210px;overflow-x: hidden;">
			<table id="resultTable" border="1" cellspacing="-1" width="880">
				<tr>
					<th>Book No</th>
					<th>Title</th>
					<th>Author</th>
					<th>Date</th>
				</tr>
			</table>
		</div>

	</div>
	<script>
		$(document)
				.ready(
						function() {
							$('#bookSearchForm')
									.submit(
											function() {
												requestPost(
														$(this).attr('action'),
														$(this).serialize(),
														function(out) {
															//alert(out.msg);
															var results = '';
															for ( var i = 0; i < out.length; i++) {
																results += '<tr><th style="font-weight:normal"><a href="javascript:openBookView('+ out[i].BookNo +')">'
																		+ out[i].BookNo
																		+ '</a></th><th style="font-weight:normal">'
																		+ out[i].Title
																		+ '</th><th style="font-weight:normal">'
																		+ out[i].Author
																		+ '</th><th style="font-weight:normal">'
																		+ out[i].Date
																		+ '</th></tr>'
															}
															//alert(out[0].Author);
															//alert(out);

															$('#resultTable')
																	.html(
																			'<tr><th>Book No</th><th>Title</th><th>Author</th><th>Date</th></tr>'
																					+ results);

														}, 'json');
												return false;

											});
						});
	
		function openBookView(bookId){
			doOverlayOpen('${WEB_BASE}jsp/Search/ViewBooks.jsp?bookNo='+bookId);
			return false;
		};
	
	</script>

</body>
</html>
